package com.xiaoxi.exam.utils;

import com.xiaoxi.exam.bean.enums.UserSource;
import com.xiaoxi.exam.bean.enums.UserStatus;
import com.xiaoxi.exam.bean.request.AddTelRequest;
import com.xiaoxi.exam.model.User;
import java.util.Random;

public class UserFactory {

  public static User toUser(User user, AddTelRequest request) {
    user.setOpenid(request.getOpenid());
    user.setSource(UserSource.WECHAT);
    user.setTel(request.getMobile());
    user.setVerifyCode(getVerifyCode());
    return user;
  }

  public static String getVerifyCode() {
    return String.valueOf(new Random().nextInt(899999) + 100000);
  }

}
